#ifndef ERROR
#define ERROR

#include <openssl/err.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <exception>
#include <string>
#include <build.cpp>
using namespace std;

extern long _BIO_get_mem_data(BIO *b, char **pp);

string get_errors()
{
    auto bio = BIO_new(BIO_s_mem());
    if (bio == nullptr)
    {
        string out =  "GetErrors function failure 1";
        return out;
    }
    ERR_print_errors(bio);

    char* p;
    auto len = _BIO_get_mem_data(bio, &p);
    if (len <= 0)
    {
        string out =  "GetErrors function failure 2";
        return out;
    }

    BIO_free(bio);

    string out = p;
    return out;
}
#endif 